package GUILayer;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Dialog.ModalityType;

public class ViewCustomerOrders extends JDialog
{

	private final JPanel contentPanel = new JPanel();
	private JTextField textField;
	private JTable table;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args)
	{
		try
		{
			ViewCustomerOrders dialog = new ViewCustomerOrders();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public ViewCustomerOrders()
	{
		setModalityType(ModalityType.APPLICATION_MODAL);
		setTitle("Customer Orders");
		setBounds(100, 100, 450, 367);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		{
			JLabel lblCustomer = new JLabel("Customer:");
			lblCustomer.setBounds(10, 11, 100, 14);
			contentPanel.add(lblCustomer);
		}
		{
			textField = new JTextField();
			textField.setEnabled(false);
			textField.setBounds(120, 8, 150, 20);
			contentPanel.add(textField);
			textField.setColumns(10);
		}
		{
			JPanel panel = new JPanel();
			panel.setBorder(new TitledBorder(null, "Orders", TitledBorder.LEADING, TitledBorder.TOP, null, null));
			panel.setBounds(10, 36, 414, 248);
			contentPanel.add(panel);
			panel.setLayout(null);
			{
				JScrollPane scrollPane = new JScrollPane();
				scrollPane.setBounds(10, 22, 394, 126);
				panel.add(scrollPane);
				{
					table = new JTable();
					table.setModel(new DefaultTableModel(
						new Object[][] {
							{null, null, null, null},
						},
						new String[] {
							"Order no", "Order date", "Total price", "Status"
						}
					));
					scrollPane.setViewportView(table);
				}
			}
			{
				JButton btnViewInvoice = new JButton("View invoice");
				btnViewInvoice.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						ViewInvoice vi = new ViewInvoice();
						vi.setVisible(true);
					}
				});
				btnViewInvoice.setBounds(273, 159, 131, 23);
				panel.add(btnViewInvoice);
			}
			{
				JButton btnNewButton = new JButton("View items");
				btnNewButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						ViewCustomerOrder vco = new ViewCustomerOrder();
						vco.setVisible(true);
					}
				});
				btnNewButton.setBounds(10, 159, 99, 23);
				panel.add(btnNewButton);
			}
		}
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new JButton("OK");
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
			{
				JButton cancelButton = new JButton("Cancel");
				cancelButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						setVisible(false);
					}
				});
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
			}
		}
	}

}
